package com.itfreer.bpm.power.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.itfreer.bpm.power.entity.BpmRoleEntity;
import com.itfreer.power.entity.role.RoleEntity;
import com.itfreer.power.service.role.RoleService;

/**
 * 定义用户信息持久化操作类
 */
@SuppressWarnings("rawtypes")
@Transactional(readOnly = false)
@Component("BpmRoleDao")
public class BpmRoleDao implements IBpmRoleDao {
	@Autowired
	RoleService service;
	
	@Override
	public BpmRoleEntity getEntity(String arg0) {
		// TODO Auto-generated method stub
		RoleEntity entity=service.getEntity(arg0);
		BpmRoleEntity r=new BpmRoleEntity();
		if(entity!=null) {
			BeanUtils.copyProperties(entity, r);
			return r;
		}else {
			return null;
		}
	}

	@Override
	public List getEntitys(String queryFields, Map where, Map order, Integer pageSize, Integer pageIndex) {
		List<RoleEntity>
		list=service.getEntitys(queryFields, where, order, pageSize, pageIndex);
		if(list!=null && list.size()>0) {
			List<BpmRoleEntity> rlst=new ArrayList<BpmRoleEntity>();
			for(RoleEntity i:list) {
				BpmRoleEntity r=new BpmRoleEntity();
				BeanUtils.copyProperties(i, r);
				rlst.add(r);
			}
			return rlst;
		}else {
			return null;
		}
	}

	@Override
	public Long getRowCounts(Map where) {
		return service.getRowCounts(where);
	}
}
